<%--
  Created by IntelliJ IDEA.
  User: 22328
  Date: 2021/2/5
  Time: 14:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
    <meta charset="utf-8" />
    <title>焕耀商城－注册</title>
    <link rel="stylesheet" type="text/css" href="./css/reset.css">
    <link rel="stylesheet" type="text/css" href="./css/main.css">
</head>
<body>


<div class="register_con">
    <div class="l_con fl">
        <a href="../../index.jsp" class="reg_logo"><img src="images/logo.png"></a>
        <div class="reg_slogan">足不出户  ·  新鲜每一天</div>
        <div class="reg_banner"></div>
    </div>

    <div class="r_con fr">
        <div class="reg_title clearfix">
            <h1>用户注册</h1>
            <a href="./login">登录</a>
        </div>
        <div class="reg_form clearfix">
            <form onsubmit="return false" action="#" method="post" id="reg_form">
                <input type="hidden" name="" value="e">
                <ul>
                    <li>
                        <label>用户名:</label>
                        <input type="text" name="user_name" id="user_name">
                        <span class="error_tip">提示信息</span>
                    </li>
                    <li>
                        <label>密码:</label>
                        <input type="password" name="pwd" id="pwd">
                        <span class="error_tip">提示信息</span>
                    </li>
                    <li>
                        <label>确认密码:</label>
                        <input type="password" name="cpwd" id="cpwd">
                        <span class="error_tip">提示信息</span>
                    </li>
                    <li>
                        <label>邮箱:</label>
                        <input type="text" name="email" id="email">
                        <span class="error_tip">提示信息</span>
                    </li>

                    <li class="agreement">
                        <input type="checkbox" name="allow" id="allow" checked="checked">
                        <label>同意”焕耀商城用户使用协议“</label>
                        <span class="error_tip2">提示信息</span>
                    </li>
                    <li class="reg_sub">
                        <input type="button" value="注 册" id="reg_btn">
                    </li>
                </ul>
            </form>
        </div>
    </div>
</div>

<!--底部结束-->
<%@include file="bottom.jsp"%>
</body>
<script src="./js/jquery-3.1.0.min.js" type="text/javascript"></script>
<script>
    $(function () {
       $("#reg_btn").click(function () {
           var username=$("#user_name").val();
           var password=$("#pwd").val();
           var email=$("#email").val();
           $.ajax({
               url:"./checkRegister",
               type:"post",
               data:{username:username,password:password,email:email},
               success:function (res) {
                   if (res.data === '注册成功') {
                       window.location.href="./login";
                   }else {
                       alert("注册失败，请重新注册！");
                       window.location.href="./register";
                   }
               },
               error:function () {
                   alert("404.html页面")
               }
           });
       });
    });
</script>
</html>
